<?php
namespace app\mobile\controller;
use app\mobile\common\Base;
use think\Db;
use think\Session;
//保修详情
class Warrantycard extends Base
{
    public function index()
    {
        

         $data = $this->request->param(true);

        
        $is_sn=is_sn($data['sn']);
        $this->assign('real_sn',$is_sn['sn']);
        //$data['sn']=$is_sn['sn'];

         $info = Db::name('card')->where('tagslogs_sn', $is_sn['sn'])->find();
        //halt($info);
        // $info['com'] = $info['danwei'];
        // $goodstags_id = Db::name('tagslogs')->where('sn', $data['sn'])->find()['goodstags_id'];
        // $good_id = Db::name('goodstags')->where('id', $goodstags_id)->find()['good_id'];
       
        // $info['model'] = Db::name('good')->where('id', $good_id)->find()['model'];
        // $info['sn'] = $data['sn'];
        // if($info['endtime'] == 0){
        //     $info['endtime'] = '暂未激活';
        // }else if($info['endtime']>time()){
        //     $info['endtime']= date('Y-m-d', $info['addtime']) . ' 至 ' . date('Y-m-d', $info['endtime']);
        // }else{
        //     $info['endtime'] = '已过期';
        // }
        // $this->assign('info',$info);
        //halt($info);

        $card_record=Db::name('card_record')->where('id',$info['pid'])->find();
        $card_record['bg_img2']=str_replace("\\","/",$card_record['bg_img2']);
        $this->assign('card_record', $card_record);
        // $card_desc = Db::name('system')->where('id',1)->value('card_desc');
        // if(empty($card_desc)){
        //     $card_desc='';
        // }
        //$this->assign('card_desc',$card_desc);
        

    	return $this->fetch();
    }

    // public function active()
    // {
    // 	$status=0;
	// 	$msg="失败";
    // 	$data=$this->request->param();
    //     $tg=$this->getPro();
    //     $is_a=Db::name('card')->where('tagslogs_sn',$tg['sn'])->where('checkstatus','in',[0,1])->count();
    //     if($is_a>0){
    //         $msg="提交失败，已经存在激活信息";
    //     }else{
    //         $insert=[
    //             'tagslogs_sn'=>$tg['sn'],
    //             'danwei'=>$data['companyName'],
    //             'user'=>$data['name'],
    //             'phone'=>$data['companyPhone'],
    //             'mobile_phone'=>$data['phone'],
    //             'email'=>$data['email'],
    //             'addtime'=>time(),
    //             'updatetime'=>time(),
    //             'checkstatus'=>0,
    //             'bianhao'=>bh(),
    //             'ip'=>request()->ip(),
    //         ];
    //         $res=Db::name('card')->insert($insert);
            
    //         if(!empty($res)){
    //             $status=1;
    //             $msg="成功";
    //         }

    //     }
       
    // 	return json(['status'=>$status,'msg'=>$msg]);
    // }
    



}
